package com.weizai.carshop.model.entiity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.weizai.carshop.model.config.LocalDateTimeConfig;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@TableName("cart_list")
public class CartListEntity {

    @TableId(type = IdType.AUTO)
    private Long id;

    private Long userId;

    private Long goodsId;

    private Integer goodsNum;

    private BigDecimal goodsPrice;

    private String goodsNorm;

    @JsonSerialize(using = LocalDateTimeConfig.LocalDateTimeSerializer.class)
    private LocalDateTime createTime;

    @JsonSerialize(using = LocalDateTimeConfig.LocalDateTimeSerializer.class)
    private LocalDateTime updateTime;

    public BigDecimal getTotalValue() {
        return goodsPrice.multiply(BigDecimal.valueOf(goodsNum));
    }
}
